package cn.lutu.domain.service.impl;

import cn.lutu.domain.repository.ArticleRepository;
import cn.lutu.domain.repository.HotelRepository;
import cn.lutu.domain.repository.RouteRepository;
import cn.lutu.domain.repository.SpotRepository;
import cn.lutu.domain.service.SearchService;
import cn.lutu.protocol.vo.IndexSearchResultVO;
import cn.lutu.util.exception.ServiceException;
import cn.lutu.util.response.StatusCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
@Slf4j
@Repository
public class SearchServiceImpl implements SearchService {
    @Autowired
    HotelRepository hotelRepository;

    @Autowired
    SpotRepository spotRepository;

    @Autowired
    RouteRepository routeRepository;
    @Autowired
    ArticleRepository articleRepository;


    @Override
    public List<IndexSearchResultVO> indexSearch(Integer type, String key) {
        if(type>3 || type<0){
            String message = "查询失败，请提交正确的类型";
            log.warn(message);
            throw new ServiceException(StatusCode.ERROR_UNKNOWN, message);
        }
        if(key == null || key.trim() == ""){
            String message = "查询失败，请输入关键词";
            log.warn(message);
            throw new ServiceException(StatusCode.ERROR_UNKNOWN, message);
        }
        //todo 根据KEY查询酒店，景点，旅游产品，文章的详情
        if(type == 0){
//            hotelRepository.select
        }

        return null;
    }
}
